class Card {
    /**
     * 会员卡列表
     * @api {GET}         /card/members     会员卡列表
     * @apiName           /card/members
     * @apiGroup          Card
     * @apiVersion 0.1.0
     * @apiSuccessExample Success-Response:
     * {
        "code": 0,
        "msg": "success",
        "data": {
            "card": [
                {
                    "id": 1,
                    "price": "38.00", //标价
                    "actualPrice": "29.98", // 实际价格
                    "day": 30,
                    "desc": "有效期，一个月的洗车卡",
                    "status": true,
                    "createdAt": "2019-06-03T10:49:16.000Z",
                    "updatedAt": "2019-06-06T07:03:33.000Z"
                }
            ],
            "rule": {
                "membersRoles": "<p><strong>解决方法：SE_PcZhidaonwhc_ngpagmjz&amp; "
            }
        }
       }
     */
    async members(ctx) {
        const { db, Op } = ctx;
        let card = await db.Members.findAll({ where: { id: { [Op.ne]: 0 } } });
        let rule = await db.Instructions.findOne({
            where: { id: 1 },
            attributes: ['membersRoles']
        });
        ctx.success({ card, rule });
    }
    /**
     * 次卡列表
     * @api {GET}         /card/timeCard     次卡列表
     * @apiName           /card/timeCard
     * @apiGroup          Card
     * @apiVersion 0.1.0
     * @apiSuccessExample Success-Response:
     * {
        "code": 0,
        "msg": "success",
        "data": {
            "card": [
                {
                    "id": 1,
                    "price": "99.00",
                    "actualPrice": "89.99",
                    "limit": 20,
                    "effective": 365,
                    "desc": "20次，此卡，有效期一年",
                    "status": true,
                    "createdAt": "2019-06-05T08:51:28.000Z",
                    "updatedAt": "2019-06-05T08:51:30.000Z"
                }
            ],
            "rule": {
                "timeCardRoles": "<p><strong>解决方法：SE_PcZhidaonwhc_ngpagmjz&amp; "
            }
        }
       }
     */
    async timeCard(ctx) {
        const { db } = ctx;
        let card = await db.TimeCard.findAll({ order: [['id', 'DESC']] });
        let rule = await db.Instructions.findOne({
            where: { id: 1 },
            attributes: ['timeCardRoles']
        });
        ctx.success({ card, rule });
    }
}
module.exports = new Card();
